/**
 * $Id: HttpSessionProvider.java 62 2009-01-16 09:54:08Z daniele.galdi $
 */
package it.edgeworks.dsession.api;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;

/**
 * Describe a common {@link HttpSession} provider.
 *
 * @author Daniele Galdi, Ivan Diana
 * @version $Revision: 62 $
 */
public interface HttpSessionProvider {

    /**
     * Initilize the provider
     *
     * @param config The filter configuration
     * @throws ServletException If something goes wrong
     */
    public void init(FilterConfig config) throws ServletException;

    /**
     * Loads the session with the given sessionId i
     *
     * @param sessionId The session identifier to load
     * @param session   The session to use for loading
     * @return <code>true</code> if the session is present, <code>false</code> otherwise.
     */
    public boolean loadSession(String sessionId, HttpSession session);

    /**
     * Saves the session with the given sessionId
     *
     * @param sessionId The session identifier to save
     * @param session   The session to use
     */
    public void saveSession(String sessionId, HttpSession session);

    /**
     * Destroy the provider
     */
    public void destroy();
}
